//
//  OperationDataBaseModel.h
//  QRMaster
//
//  Created by myApple on 15/12/21.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDatabaseQueue.h"
#import "FMResultSet.h"

typedef void(^resultBlock)(FMResultSet * set);

@interface OperationDataBaseModel : NSObject

+(FMDatabaseQueue *)shareFMDatabaseQueue;

//删除表数据
-(void)truncateTable;


/**
 *  对表进行插入数据
 *
 *  @param tableName 表名
 *  @param dict      需要插入的数据
 */
-(void)insertDataTable:(NSString *)tableName
              withDict:(NSMutableDictionary *)dict;


/**
 *  查询数据库
 *
 *  @param tableName 表名
 *  @param condition 查询条件
 *  @param resultSet 查询结果
 */
-(void)queryDataFromTable:(NSString *)tableName
            withCondition:(NSString *)condition
                    block:(resultBlock)resultSet;



/**
 *  删除数据
 *
 *  @param tableName 表名
 *  @param condition 删除的条件
 */
-(void)deleteDataFromTable:(NSString *)tableName
             withCondition:(NSString *)condition;


/**
 *  更新数据
 *
 *  @param tableName 表名
 *  @param condition 更新条件
 *  @param dict      需要更新的字段
 */
-(void)updateDataFromTable:(NSString *)tableName
             withCondition:(NSString *)condition
                  withDict:(NSMutableDictionary *)dict;

/*
 *  查找时间戳
 *
 *  @param tableName 表名
 *  @param key       时间戳的字段名称
 *  @param condition 查询的条件
 *
 *  @return          返回时间戳
 */
-(NSString *)getTimeFromTable:(NSString *)tableName
                   selectTime:(NSString *)key
                withCondition:(NSString *)condition;


-(void)deleteDataFromTableByCommunityId:(NSString *)tableName communityId:(NSString *)communityId;


-(void)deleteBulidingFromTableByCommunityId:(NSString *)tableName communityId:(NSString *)communityId;

/*
 * 删除表
 *  @param tableName 表名
 */
-(void)deleteTable:(NSString *)tableName;

@end
